home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / pascal / mouse.exe / MOUSE.PAS < prev    next >
Pascal/Delphi Source File  |  1988-06-02  |  42KB  |  1,015 lines

  1. {$O-,R-,I-,V-,F+}
  2. Unit Mouse;
  3. {$UNDEF  GMouse}
  4. {$DEFINE GMouse} {<-- if you are not using graphics remove this definition}
  5.  
  6. {***************************************************************************}
  7. {*              Mouse - Turbo Pascal Mouse Unit Version 3.1                *}
  8. {*                      by Michael Day  05/28/89                           *}
  9. {*                                                                         *}
  10. {*    Based on the Mouse4 unit developed by Richard Sadowsky 11/20/87      *}
  11. {*           Graphics cursor procedure borrowed from EgaMouse              *}
  12. {*                    by Eduardo Martins 02/02/88                          *}
  13. {*                                                                         *}
  14. {*           This program is released to the public domain                 *}
  15. {*                                                                         *}
  16. {*        This program assumes that you have a MS (or compatible)          *}
  17. {*                 mouse driver installed on the computer.                 *}
  18. {*                                                                         *}
  19. {***************************************************************************}
  20.  
  21. { History }
  22.  
  23. { V2.0 First release under this package unkown date -med}
  24. { V2.1 as of 09/10/88 First full release of this package -med}
  25. { V2.2 as of 09/15/88 Corrected Graphic cursor bug in V2.1 which had }
  26. { incorrect tables for some cursors. Also improved the table structure }
  27. { at the same time. -med }
  28. { V2.3 as of 09/28/88 Corrected bug in release V2.2 to fix mouse detect }
  29. { crash when running under DOS 2.x. -med }
  30. { V2.4 as of 04/08/89 fixed checkmark cursor and circle target cursor -med}
  31. { V3.0 as of 05/23/89 added BGI mouse emulation for EGA debugging -med}
  32. { V3.1 as of 05/29/89 added Hercules page control fix BGI mouse cursor}
  33. { to deal with BGI screen edge problem (redraws mouse at edge). -med}
  34.  
  35. {***************************************************************************}
  36.  
  37.  
  38. Interface
  39.  
  40. {$IFDEF GMouse}
  41.   Uses DOS,Graph{,crt};
  42. {$ELSE}
  43.   Uses DOS;
  44. {$ENDIF}
  45.  
  46. {---------------------------------------------------------------------------}
  47. {Externally accessable constants}
  48.  
  49. const
  50.  
  51.   MouseLeftButton   = 1;                               {what the buttons are}
  52.   MouseRightButton  = 2;
  53.   MouseCenterButton = 4;
  54.  
  55.   MouseStandard     = 1;                         {graphic cursor definitions}
  56.   MouseUpArrow      = 2;
  57.   MouseDownArrow    = 3;
  58.   MouseLeftArrow    = 4;
  59.   MouseRightArrow   = 5;
  60.   MouseCheckMark    = 6;
  61.   MouseUpHand       = 7;
  62.   MouseDownHand     = 8;
  63.   MouseLeftHand     = 9;
  64.   MouseRightHand    = 10;
  65.   MouseStopHand     = 11;
  66.   MouseHourGlass    = 12;
  67.   MouseDiagCross    = 13;
  68.   MouseRectCross    = 14;
  69.   MouseRectBox      = 15;
  70.   MouseTargetCross  = 16;
  71.   MouseTargetCircle = 17;
  72.   MouseTargetBox    = 18;
  73.   MouseQuestionMark = 19;
  74.  
  75.   MaxMouseGraphShape = 19;
  76.   MaxMouseTextShape  = 15;
  77.  
  78. {---------------------------------------------------------------------------}
  79. {Externally accessable variables}
  80.  
  81. var  CrtMode : Byte absolute $40:$49;               {BIOS Crt mode flag byte}
  82.      CrtCols : Word absolute $40:$4A;                 {BIOS Crt column count}
  83.      CrtRows : Byte absolute $40:$84;                    {BIOS Crt row count}
  84.      SysClk  : Word absolute $40:$6C;             {BIOS system clock counter}
  85.      CursorMode : Word absolute $40:$60;           {BIOS cursor mode storage}
  86.  
  87. var
  88.   MouseInstalled   : Boolean;   {InitMouse - True if mouse is operable}
  89.   MouseError       : Integer;   {InitMouse - Error code}
  90.   MouseType        : Integer;   {InitMouse - Mouse Type}
  91.  
  92.   MouseClicked     : Boolean;   {ReadMouse - True if button was clicked}
  93.   MouseButtons     : Word;      {ReadMouse - Current mouse button status}
  94.   MouseClickButton : Word;      {ReadMouse - Click button status}
  95.   MouseX           : Integer;   {ReadMouse - Mouse X Position}
  96.   MouseY           : Integer;   {ReadMouse - Mouse Y Position}
  97.   ClickMouseX      : Integer;   {ReadMouse - Mouse X Click Position}
  98.   ClickMouseY      : Integer;   {ReadMouse - Mouse Y Click Position}
  99.   MousePressX      : Integer;   {last mouse button press position}
  100.   MousePressY      : Integer;
  101.   MouseReleaseX    : Integer;   {last mouse button release position}
  102.   MouseReleaseY    : Integer;
  103.  
  104.   MouseHideX1      : Integer;
  105.   MouseHideY1      : Integer;   {HideMouseArea - Mouse hide area}
  106.   MouseHideX2      : Integer;
  107.   MouseHideY2      : Integer;
  108.   MouseAreaX1      : Integer;   {SetMouseArea - Mouse bounded area}
  109.   MouseAreaY1      : Integer;
  110.   MouseAreaX2      : Integer;
  111.   MouseAreaY2      : Integer;
  112.  
  113. const
  114.   MouseGShape        : Integer = 1;            {selected graphic mouse shape}
  115.   MouseTShape        : Integer = 0;               {selected text mouse shape}
  116.   MouseState         : Integer = -1;                {Negative = mouse hidden}
  117.   MouseVisible       : Boolean = false;             {true = mouse is visible}
  118.   MouseCondo         : Boolean = false;     {true = conditional mouse hiding}
  119.   MouseReDraw        : Boolean = false;    {true = mouse needs to be redrawn}
  120.   MouseHooked        : Boolean = false;    {true = mouse hooked to clock int}
  121.   TextMouse          : Boolean = false;         {true = text mode type mouse}
  122.   ZeroMouse          : Boolean = false;       {true = text mouse starts at 0}
  123.   HercGraphMouse     : Boolean = false;        {true = Herc graph mode mouse}
  124.  
  125.   MouseTextWidth     : Word = 8;           {size of text on screen for mouse}
  126.   MouseTextHeight    : Word = 8;
  127.   MaxCrtX            : Word = 80;                 {screen size in characters}
  128.   MaxCrtY            : Word = 25;
  129.  
  130.   MouseColor         : Word = $FFFF;                     {mouse cursor color}
  131.   UseMouseSim        : Boolean = false;   {true = use simulated mouse cursor}
  132.   MouseImageX        : Integer = 0;         {current mouse XY image position}
  133.   MouseImageY        : Integer = 0;
  134.  
  135. {---------------------------------------------------------------------------}
  136. type      MaskType = record                 {mouse graphic cursor definition}
  137.                   Def: array [0..1, 0..15] of word;     {graphics cursor def}
  138.                   HotX, HotY: integer;                       { hot spot X,Y }
  139.                 end;
  140.  
  141. { define what the mouse text cursor definition array looks like }
  142. type MouseTextType = record
  143.                   Select : Word;
  144.                   Start  : Word;
  145.                   Stop   : Word;
  146.                 end;
  147.  
  148. {---------------------------------------------------------------------------}
  149. {Note: You must set the MouseTextWidth and MouseTextHeight values}
  150. {to the current character pixel width and height to properly use the}
  151. {mouse text X,Y coordinate system. Startup Default is 8x8.}
  152. {To start up the mouse you should do the following: }
  153. {InitMouse; ReadMouse; ShowMouse; - This insures that the mouse is}
  154. {properly setup and ready to run. Additionally, if you have a Hercules}
  155. {display, you must call SetHercPage prior to calling InitMouse to properly}
  156. {initialize the mouse driver for the Hercules display.}
  157.  
  158. {For more information on the mouse interface and programming with }
  159. {with a mouse refer to the MicroSoft Mouse Programmer's Reference Guide}
  160. {Available from MicroSoft Corporation.}
  161.  
  162. {Warning: All mouse drivers are not created equal. Nor are programs that }
  163. {use them. Be especially careful with the MouseAreaHide function, if you }
  164. {are using an EGA display with Turbo Pascal it will not work. The area }
  165. {hide function requires that certain EGA display calls be performed through }
  166. {an extended video BIOS call so that it can know what to expect in how the }
  167. {display is setup. Since Turbo Pascal does not do this, The MouseAreaHide }
  168. {function will not currently work under Turbo Pascal. With other displays }
  169. {you shouldn't have a problem. Also be aware that some mouse drivers do not }
  170. {impliment all functions exactly the same, and that the early MS mouse driver}
  171. {did not impliment all the functions listed here. If you have any questions}
  172. {check with your mouse m